package org.tity.test.entity.raw.sys;

import org.tity.sql.entity.EntitySet;
import org.tity.sql.data.RcdSet;
import org.tity.sql.data.Rcd;
import java.util.Map;
import java.util.List;
import org.tity.test.entity.raw.sys.DictItemSet;
import org.tity.sql.entity.JoinParameter;
import org.tity.sql.sql.builder.SE;
import org.tity.sql.entity.builder.naming.DefaultNameConvertor;
import org.tity.sql.entity.JoinImplType;
import org.tity.sql.entity.builder.RelationType;



/*
 * 此类代码为自动生成，请勿修改 !
 */

/**
 * 
 * @author tity-code-builder-powered-by-lifangjie
 * @date 2019-02-13 09:57:00
 **/
public class DictSet extends EntitySet<Dict> {

	public DictSet(RcdSet rs) {
		super(rs);
	}

	/**
	 * 构造函数,构建空集合
	*/
	public DictSet() {
		super(null);
	}

	@Override 
	public Dict createEntity(Rcd r) {
		return new Dict(this,r);
	}

	/**
	 * 快速构建函数,从Map构建,null值或非Dict类型的对象忽略
	*/
	public static DictSet fromMap(Map map) {
		DictSet set=new DictSet();
		Object obj=null;
		for (Object key : map.keySet()) {
			obj=map.get(key);
			if(obj==null || !(obj instanceof Dict)) {continue;}
			set.addEntity((Dict)obj);
		}
		return set;
	}

	/**
	 * 快速构建函数,从List构建,null值或非Dict类型的对象忽略
	*/
	public static DictSet fromList(List list) {
		DictSet set=new DictSet();
		for (Object obj : list) {
			if(obj==null || !(obj instanceof Dict)) {continue;}
			set.addEntity((Dict)obj);
		}
		return set;
	}

	public DictItemSet joinDictItems() {
		JoinParameter join=new JoinParameter("join-dictitem-on(local.id=entity.dict_id)",DictItemSet.class);
		join.setLocalJoinFields("id");
		join.setNameConvertorType(DefaultNameConvertor.class);
		join.setJoinImplType(JoinImplType.AUTO);
		join.setEntityQuerySQL(new SE("select * from sys_dict_item"));
		join.setRelationType(RelationType.ONE_TO_MANY,RelationType.ONE_TO_ONE);
		join.setEntityJoinFields("dict_id");
		return (DictItemSet) this.join(join);
	}

}
